<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <link rel="stylesheet" href="../css/index.css">
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>

<body>
    <!-- 页面头部内容 -->
    <header>
        <div class="header_main">
            <div class="header_left">
                北游论坛
            </div>
            <div class="header_right">
                <!-- <div>
                    <span class="glyphicon glyphicon-plus"></span> 发表
                </div> -->
                <div class="regest">
                    <span class="glyphicon glyphicon-user"></span> 注册
                </div>
            </div>
        </div>
    </header>
    <div class="biaodan">
        <div class="form-group">
            <label for="name">账号</label>
            <input type="text" class="form-control" placeholder="请输入用户名" id="username">
        </div>
        <div class="form-group">
            <label for="name">密码</label>
            <input type="password" class="form-control" placeholder="请输入密码" id="password">
        </div>
        <div class="form-group">
            <button type="button" class="btn btn-success btn-block" id="login">登录</button>
        </div>
    </div>
</body>
<script src="../js/jquery.js"></script>
<script src="../js/ajax.js"></script>
<script>
    $(".regest").click(() => {
        window.location.href = './regiest.html'
    })
    $(".header_left").click(() => {
        window.location.href = '/'
    })
    $("#login").click(async ()=>{
          // 获取输入框内容
          let username = $("#username").val();
        let password = $("#password").val();
        // 判断是否都有值
        if(!username || !password ){
            alert("请您先补充完整信息")
            return
        }
        let res = await request("/user/login",'post',{username,password});
        console.log(res)
        if(res.code == 0){
            window.location.href = '/'
        }else{
            alert(res.msg)
        }
    })
</script>

</html>